

var $, form;
layui.use(["form","upload"], function () {
    $ = layui.$
        , form = layui.form;
    var id = getPar('id');
    if(id>0){
    layer.load(1)

        $.ajax({
            url: './info',
            type: 'GET',
            data: {id: id},
            success: function (result) {
                if (result.code == 200) {
                    //layuiadmin-form-role 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                    //给表单赋值
                    form.val("layuiadmin-form-role",result.data);
                    
                } else {
                    layer.msg(result.message)
                }
                layer.closeAll();
            }
        });
    }

    var  upload = layui.upload;

//指定允许上传的文件类型
        upload.render({
            elem: '#touxiang_upload'
            ,url: '/admin/upload/img'
            ,accept: 'file' //普通文件
            ,done: function(res){
                $("#touxiang_show_img").attr('src',res.data+"?_="+Math.random());
                $("#touxiang").val(res.data);
            }
        });

})